package file;

import java.io.File;
import java.io.FileFilter;

/**
 * 获取./src/main/java/file路径下所有名字以D开头的子项目
 */
public class Test {
    public static void main(String[] args) {
        File dir = new File("./src/main/java/file");

        if (dir.isDirectory()) {
            FileFilter filter = new FileFilter() {
                @Override//文件过滤器
                public boolean accept(File pathname) {
                    //String name = pathname.getName();//获取文件名称
                    long len = pathname.length();//获取文件字节大小
                    return len <= 800;
                }

            };


            File[] subs = dir.listFiles(filter);
            for (File sub : subs) {
                System.out.println(sub.getName());

            }
        }
    }
}
